﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CRMSalesManagement.Manage.FrontPageManagement
{
    public partial class MainWebIntent : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int pageNum = 1;
                if (Request.QueryString["page"] != null)
                {
                    pageNum = int.Parse(Request.QueryString["page"]);
                }
                int total = 0;
                var columnDb = CRM.Business.WebIntent.PageListWebIntent(out total, pageNum, this.DataPage1.ShowRecordCount);
                this.DataPage1.TotalRecordCount = total;
                this.DataPage1.ShowPageNumberCount = pageNum;
                if (columnDb != null)
                {
                    //留言总数
                    this.lblTotal.Text = total.ToString();
                    //通过发布的留言数
                    this.lblRemain.Text = CRM.Business.WebIntent.GetDisposeCount().ToString();
                    this.gvWebIntent.DataSource = columnDb;
                    this.gvWebIntent.DataBind();
                }

                #region 控制分页控件
                CRM.Business.ShowPageDispaly.PageDispaly(this.DataPage1, pageNum, total);
                #endregion
            }
        }

        protected void gvWebIntent_RowEditing(object sender, GridViewEditEventArgs e)
        {
            Session["webIntentId"] = Convert.ToInt32(gvWebIntent.DataKeys[e.NewEditIndex].Value);
            Response.Redirect("DetailWebIntent.aspx");
        }

        protected void gvWebIntent_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.Cells[4].Text != "False")
                    e.Row.Cells[4].Text = "已处理";
                else
                    e.Row.Cells[4].Text = "未处理";
            }
        }
    }
}